﻿namespace ACCOUNTING
{
    using ACCOUNTING.Encryption;
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My.Resources;
    using HardwareMotherboardID.nsMotherBoardID;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_DangKyBanQuyen : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CmdDangKy")]
        private Button _CmdDangKy;
        [AccessedThroughProperty("CmdThoat")]
        private Button _CmdThoat;
        [AccessedThroughProperty("GroupBox1")]
        private GroupBox _GroupBox1;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("Label3")]
        private Label _Label3;
        [AccessedThroughProperty("LblMessage")]
        private Label _LblMessage;
        [AccessedThroughProperty("LinkLabel1")]
        private LinkLabel _LinkLabel1;
        [AccessedThroughProperty("TxtCPUCode")]
        private TextBox _TxtCPUCode;
        [AccessedThroughProperty("TxtHDDCode")]
        private TextBox _TxtHDDCode;
        [AccessedThroughProperty("TxtSerialKey")]
        private TextBox _TxtSerialKey;
        private IContainer components;
        public object objFrmCall;
        public string RegSubKeyName;
        public Data skey;
        private string strPathXML;

        public Frm_DangKyBanQuyen()
        {
            base.Load += new EventHandler(this.Frm_DangKyBanQuyen_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.skey = new Data("RandomPassword");
            this.RegSubKeyName = "DRAGON";
            this.strPathXML = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DRAGON2\LVY.xml";
            this.InitializeComponent();
        }

        public void AuthorizeComputer(string Username, string RegCode)
        {
            object obj2 = this.getMotherboardId().ToString().Trim();
            LVYModule.OpenFileLicense();
            LVYModule.WriteValueElementFromXML(this.strPathXML, "USERID", Username.ToString().Trim());
            LVYModule.WriteValueElementFromXML(this.strPathXML, "LOCALPATH", RegCode.ToString().Trim());
            LVYModule.WriteValueElementFromXML(this.strPathXML, "Enable", "");
            LVYModule.WriteValueElementFromXML(this.strPathXML, "CompID", obj2.ToString().Trim());
            LVYModule.CloseFileLicense();
        }

        private void CmdDangKy_Click(object sender, EventArgs e)
        {
            string str = this.GetSerialKey(this.TxtHDDCode.ToString().Trim(), this.TxtCPUCode.Text.Trim()).ToString().Trim();
            if (this.TxtSerialKey.Text.Trim() == str)
            {
                this.AuthorizeComputer(this.TxtCPUCode.Text.Trim(), this.TxtHDDCode.Text.Trim());
                LVYModule.ShowWarning("Chương tr\x00ecnh bạn đ\x00e3 được đăng k\x00fd bản quyền ! ");
                NewLateBinding.LateSetComplex(NewLateBinding.LateGet(this.objFrmCall, null, "ToolStripMenuItem_DKBQ", new object[0], null, null, null), null, "Visible", new object[] { false }, null, null, false, true);
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                LVYModule.ShowWarning("M\x00e3 số k\x00edch hoạt kh\x00f4ng ph\x00f9 hợp");
            }
        }

        private void CmdThoat_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void Frm_DangKyBanQuyen_Load(object sender, EventArgs e)
        {
            this.TxtHDDCode.Text = GetMachineInfoModule.GetVolumeSerial("");
            this.TxtCPUCode.Text = GetMachineInfoModule.GetCPUId();
        }

        public object getMotherboardId()
        {
            return NewLateBinding.LateGet(LVYModule.ReturnIfNull(MotherBoardID.GetMotherBoardID(), "", modGeneral.TypeOfValue.Nothing), null, "Trim", new object[0], null, null, null).ToString();
        }

        public object GetSerialKey(string pHDDCode, string pCPUCode)
        {
            int num5 = 5;
            int num4 = 10;
            pHDDCode = pHDDCode.ToUpper();
            pCPUCode = pCPUCode.ToUpper();
            int length = pHDDCode.Length;
            int num2 = pCPUCode.Length;
            pHDDCode = pHDDCode.Substring(length - num5);
            pCPUCode = pCPUCode.Substring(num2 - num4);
            string str2 = "";
            string pCharacter = "";
            int num6 = num4 - 1;
            for (int i = 0; i <= num6; i++)
            {
                pCharacter = "";
                if (((i % 2) == 0) & ((((double) i) / 2.0) < num4))
                {
                    pCharacter = pHDDCode[(int) Math.Round((double) ((num5 - (((double) i) / 2.0)) - 1.0))].ToString();
                }
                str2 = str2 + this.GetSyn(pCharacter);
                pCharacter = Conversions.ToString(pCPUCode[i]);
                str2 = str2 + this.GetSyn(pCharacter);
            }
            return str2;
        }

        public string GetSyn(string pCharacter)
        {
            string[] pArray = new string[] { "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T" };
            string[] strArray2 = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" };
            string[] strArray3 = new string[] { "U", "V", "W", "X", "Y", "Z" };
            if (pCharacter != "")
            {
                if (this.SearchKeyArr(pCharacter, pArray))
                {
                    pCharacter = pArray[Conversions.ToInteger(pCharacter)];
                    return pCharacter;
                }
                int num = this.SearchValueArr(pCharacter, pArray);
                if (num != -1)
                {
                    pCharacter = Conversions.ToString(num);
                    return pCharacter;
                }
                if (this.SearchKeyArr(pCharacter, strArray2))
                {
                    pCharacter = strArray2[Conversions.ToInteger(pCharacter)];
                    return pCharacter;
                }
                num = this.SearchValueArr(pCharacter, strArray2);
                if (num != -1)
                {
                    pCharacter = Conversions.ToString(num);
                    return pCharacter;
                }
                if (this.SearchKeyArr(pCharacter, strArray3))
                {
                    pCharacter = strArray3[Conversions.ToInteger(pCharacter)];
                    return pCharacter;
                }
                num = this.SearchValueArr(pCharacter, strArray3);
                if (num != -1)
                {
                    pCharacter = Conversions.ToString(num);
                }
            }
            return pCharacter;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            this.GroupBox1 = new GroupBox();
            this.TxtSerialKey = new TextBox();
            this.TxtCPUCode = new TextBox();
            this.TxtHDDCode = new TextBox();
            this.Label2 = new Label();
            this.Label1 = new Label();
            this.Label3 = new Label();
            this.CmdDangKy = new Button();
            this.CmdThoat = new Button();
            this.LinkLabel1 = new LinkLabel();
            this.LblMessage = new Label();
            this.GroupBox1.SuspendLayout();
            this.SuspendLayout();
            this.GroupBox1.BackColor = Color.Transparent;
            this.GroupBox1.Controls.Add(this.TxtSerialKey);
            this.GroupBox1.Controls.Add(this.TxtCPUCode);
            this.GroupBox1.Controls.Add(this.TxtHDDCode);
            this.GroupBox1.Controls.Add(this.Label2);
            this.GroupBox1.Controls.Add(this.Label1);
            this.GroupBox1.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            Point point = new Point(6, 0x5e);
            this.GroupBox1.Location = point;
            this.GroupBox1.Name = "GroupBox1";
            Size size = new Size(0x1c3, 0x60);
            this.GroupBox1.Size = size;
            this.GroupBox1.TabIndex = 0;
            this.GroupBox1.TabStop = false;
            this.GroupBox1.Text = "Th\x00f4ng tin đăng k\x00fd bản quyền";
            point = new Point(0x66, 0x37);
            this.TxtSerialKey.Location = point;
            this.TxtSerialKey.Name = "TxtSerialKey";
            size = new Size(0x14e, 20);
            this.TxtSerialKey.Size = size;
            this.TxtSerialKey.TabIndex = 3;
            point = new Point(0xda, 0x18);
            this.TxtCPUCode.Location = point;
            this.TxtCPUCode.Name = "TxtCPUCode";
            this.TxtCPUCode.ReadOnly = true;
            size = new Size(0xda, 20);
            this.TxtCPUCode.Size = size;
            this.TxtCPUCode.TabIndex = 2;
            point = new Point(0x66, 0x18);
            this.TxtHDDCode.Location = point;
            this.TxtHDDCode.Name = "TxtHDDCode";
            this.TxtHDDCode.ReadOnly = true;
            size = new Size(0x72, 20);
            this.TxtHDDCode.Size = size;
            this.TxtHDDCode.TabIndex = 1;
            this.Label2.AutoSize = true;
            point = new Point(14, 0x3a);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x55, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 0;
            this.Label2.Text = "M\x00e3 số k\x00edch hoạt";
            this.Label1.AutoSize = true;
            point = new Point(14, 0x1b);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x4e, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 0;
            this.Label1.Text = "M\x00e3 số đăng k\x00fd";
            this.Label3.BackColor = Color.Transparent;
            this.Label3.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            point = new Point(12, 0x3b);
            this.Label3.Location = point;
            this.Label3.Name = "Label3";
            size = new Size(0x1bd, 0x20);
            this.Label3.Size = size;
            this.Label3.TabIndex = 1;
            this.Label3.Text = "Qu\x00fd kh\x00e1ch gửi mail th\x00f4ng tin c\x00f4ng ty m\x00ecnh k\x00e8m hai m\x00e3 số đăng k\x00fd để nhận m\x00e3 số k\x00edch hoạt.";
            this.CmdDangKy.Image = ACCOUNTING.My.Resources.Resources.Selected;
            this.CmdDangKy.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x11c, 0xc5);
            this.CmdDangKy.Location = point;
            this.CmdDangKy.Name = "CmdDangKy";
            size = new Size(0x57, 0x17);
            this.CmdDangKy.Size = size;
            this.CmdDangKy.TabIndex = 2;
            this.CmdDangKy.Text = "Đăng k\x00fd";
            this.CmdDangKy.UseVisualStyleBackColor = true;
            this.CmdThoat.Image = ACCOUNTING.My.Resources.Resources.Closed;
            this.CmdThoat.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x17e, 0xc4);
            this.CmdThoat.Location = point;
            this.CmdThoat.Name = "CmdThoat";
            size = new Size(0x4b, 0x17);
            this.CmdThoat.Size = size;
            this.CmdThoat.TabIndex = 2;
            this.CmdThoat.Text = "Tho\x00e1t";
            this.CmdThoat.UseVisualStyleBackColor = true;
            this.LinkLabel1.AutoSize = true;
            this.LinkLabel1.BackColor = Color.Transparent;
            point = new Point(10, 0xca);
            this.LinkLabel1.Location = point;
            this.LinkLabel1.Name = "LinkLabel1";
            size = new Size(0x93, 13);
            this.LinkLabel1.Size = size;
            this.LinkLabel1.TabIndex = 3;
            this.LinkLabel1.TabStop = true;
            this.LinkLabel1.Text = "Đăng k\x00fd tại website ch\x00fang t\x00f4i";
            this.LblMessage.BackColor = Color.Transparent;
            this.LblMessage.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            point = new Point(10, 0x11);
            this.LblMessage.Location = point;
            this.LblMessage.Name = "LblMessage";
            size = new Size(0x1bd, 0x20);
            this.LblMessage.Size = size;
            this.LblMessage.TabIndex = 1;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.background;
            size = new Size(0x1d7, 0xe5);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.LinkLabel1);
            this.Controls.Add(this.CmdThoat);
            this.Controls.Add(this.CmdDangKy);
            this.Controls.Add(this.LblMessage);
            this.Controls.Add(this.Label3);
            this.Controls.Add(this.GroupBox1);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.Name = "Frm_DangKyBanQuyen";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "DANG KY BAN QUYEN";
            this.GroupBox1.ResumeLayout(false);
            this.GroupBox1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //Process.Start("IExplore.exe", "http://www.dragon2.com.vn/index.php?option=com_supports&task=get-code&hd=" + this.TxtHDDCode.Text + "&cpu=" + this.TxtCPUCode.Text + "&Itemid=33");
        }

        public bool SearchKeyArr(string pKey, string[] pArray)
        {
            int num = 0;
            if (Versioned.IsNumeric(pKey))
            {
                int num2 = pArray.Length - 1;
                for (num = 0; num <= num2; num++)
                {
                    if (num == Conversions.ToDouble(pKey))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        public int SearchValueArr(string pValue, string[] pArray)
        {
            int index = 0;
            int num3 = pArray.Length - 1;
            for (index = 0; index <= num3; index++)
            {
                if (pArray[index] == pValue)
                {
                    return index;
                }
            }
            return -1;
        }

        internal virtual Button CmdDangKy
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdDangKy;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdDangKy_Click);
                if (this._CmdDangKy != null)
                {
                    this._CmdDangKy.Click -= handler;
                }
                this._CmdDangKy = value;
                if (this._CmdDangKy != null)
                {
                    this._CmdDangKy.Click += handler;
                }
            }
        }

        internal virtual Button CmdThoat
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdThoat;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdThoat_Click);
                if (this._CmdThoat != null)
                {
                    this._CmdThoat.Click -= handler;
                }
                this._CmdThoat = value;
                if (this._CmdThoat != null)
                {
                    this._CmdThoat.Click += handler;
                }
            }
        }

        internal virtual GroupBox GroupBox1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._GroupBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._GroupBox1 = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label3
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label3;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label3 = value;
            }
        }

        public virtual Label LblMessage
        {
            [DebuggerNonUserCode]
            get
            {
                return this._LblMessage;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._LblMessage = value;
            }
        }

        internal virtual LinkLabel LinkLabel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._LinkLabel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                LinkLabelLinkClickedEventHandler handler = new LinkLabelLinkClickedEventHandler(this.LinkLabel1_LinkClicked);
                if (this._LinkLabel1 != null)
                {
                    this._LinkLabel1.LinkClicked -= handler;
                }
                this._LinkLabel1 = value;
                if (this._LinkLabel1 != null)
                {
                    this._LinkLabel1.LinkClicked += handler;
                }
            }
        }

        internal virtual TextBox TxtCPUCode
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtCPUCode;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtCPUCode = value;
            }
        }

        internal virtual TextBox TxtHDDCode
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtHDDCode;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtHDDCode = value;
            }
        }

        internal virtual TextBox TxtSerialKey
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtSerialKey;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtSerialKey = value;
            }
        }
    }
}

